﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nage.Algorithms.Population;
using Nage.Algorithms.Solution;

namespace Nage.Examples.Rastrigin.Solution
{
    public class RastriginFunctionEvaluator : ISolutionEvaluator<Coordinates>
    {
        public double Evaluate(Coordinates solution)
        {
            int dim = solution.Vector.Length;
            double a = 10;
            double value = a * dim;
            foreach (double x in solution.Vector)
            {
                value += x * x - a * Math.Cos(2 * Math.PI * x);
            }
            return value;
        }
    }
}
